package com.education.wisdom.service.impl;

import com.education.common.utils.Convert;
import com.education.wisdom.mapper.SysAppLoginMapper;
import com.education.wisdom.pojo.SysAppLogin;
import com.education.wisdom.pojo.SysAppTeacherstudent;
import com.education.wisdom.pojo.UserConstants;
import com.education.wisdom.service.ISysAppLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 系统用户 服务层实现
 *
 * @author ruoyi
 * @date 2018-10-25
 */
@Service
public class SysAppLoginServiceImpl implements ISysAppLoginService {
    @Autowired
    private com.education.wisdom.mapper.SysAppLoginMapper SysAppLoginMapper;

    /**
     * 查询系统用户信息
     *
     * @param userId 系统用户ID
     * @return 系统用户信息
     */
    @Override
    public SysAppLogin selectSysAppLoginById(String userId) {
        return SysAppLoginMapper.selectSysAppLoginById(userId);
    }

    /**
     * 查询系统用户列表
     *
     * @param SysAppLogin 系统用户信息
     * @return 系统用户集合
     */
    @Override
    public List<SysAppLogin> selectSysAppLoginList(SysAppLogin SysAppLogin) {
        return SysAppLoginMapper.selectSysAppLoginList(SysAppLogin);
    }

    @Override
    public List<SysAppLogin> selectstudentByteacher(SysAppTeacherstudent sysAppTeacherstudent) {
        return SysAppLoginMapper.selectstudentByteacher(sysAppTeacherstudent);
    }

    /**
     * 新增系统用户
     *
     * @param SysAppLogin 系统用户信息
     * @return 结果
     */
    @Override
    public int insertSysAppLogin(SysAppLogin SysAppLogin) {
        return SysAppLoginMapper.insertSysAppLogin(SysAppLogin);
    }

    /**
     * 修改系统用户
     *
     * @param SysAppLogin 系统用户信息
     * @return 结果
     */
    @Override
    public int updateSysAppLogin(SysAppLogin SysAppLogin) {
        return SysAppLoginMapper.updateSysAppLogin(SysAppLogin);
    }

    @Override
    public int updateSysAppLoginbyuserPhone(SysAppLogin SysAppLogin) {
        return SysAppLoginMapper.updateSysAppLoginbyuserPhone(SysAppLogin);
    }

    /**
     * 删除系统用户对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSysAppLoginByIds(String ids) {
        return SysAppLoginMapper.deleteSysAppLoginByIds(Convert.toStrArray(ids));
    }


    /**
     * 校验用户名称是否唯一
     *
     * @param loginName 用户名
     * @return
     */
    @Override
    public int checkLoginNameUnique(String loginName) {
        int count = SysAppLoginMapper.checkLoginNameUnique(loginName);
        return count;
    }

    /**
     * 校验手机号码是否唯一
     *
     * @param userphone 手机号码
     * @return
     */
    @Override
    public String checkPhoneUnique(String userphone) {
        SysAppLogin info = SysAppLoginMapper.checkPhoneUnique(userphone);
        if (info != null) {
            return UserConstants.USER_PHONE_NOT_UNIQUE;
        }
        return UserConstants.USER_PHONE_UNIQUE;
    }

    /**
     * 通过手机号查询
     *
     * @param phone
     * @return
     */
    @Override
    public SysAppLogin selectByPhone(String phone) {
        return SysAppLoginMapper.checkPhoneUnique(phone);
    }

    /**
     * 校验email是否唯一
     *
     * @param useremail 电子邮箱
     * @return
     */
    @Override
    public String checkEmailUnique(String useremail) {
        SysAppLogin info = SysAppLoginMapper.checkEmailUnique(useremail);
        if (info != null) {
            return UserConstants.USER_EMAIL_NOT_UNIQUE;
        }
        return UserConstants.USER_EMAIL_UNIQUE;
    }

    @Override
    public SysAppLogin selectSysAppLogin(Map<String, Object> map) {
        return SysAppLoginMapper.selectSysAppLogin(map);
    }

    @Override
    public SysAppLogin selectByMap(Map<String, Object> map) {
        return SysAppLoginMapper.selectByMap(map);
    }

    @Override
    public SysAppLogin selectByDeptId(Map<String, Object> map) {
        return SysAppLoginMapper.selectByDeptId(map);
    }

    @Override
    public List<SysAppLogin> selectStudents(SysAppLogin SysAppLogin) {
        return SysAppLoginMapper.selectStudents(SysAppLogin);
    }

    @Override
    public List<SysAppLogin> selectTeachers(SysAppLogin SysAppLogin) {
        return SysAppLoginMapper.selectTeachers(SysAppLogin);
    }
}
